// Tags: DP
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e4 + 5, M = 2e3 + 5, inf = 0x3f3f3f3f;
int n, m, k, f[N][M], x[N], y[N], h[N], l[N];
bool flag[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("P1941 飞扬的小鸟.in", "r", stdin);
  freopen("P1941 飞扬的小鸟.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) { scanf("%d%d", &x[i], &y[i]); }
  memset(f, inf, sizeof(f));
  memset(h, inf, sizeof(h));
  for (int i = 1, p; i <= k; ++i) {
    scanf("%d", &p);
    flag[p] = true;
    scanf("%d%d", &l[p], &h[p]);
  }
  for (int i = 0; i <= m; ++i) f[0][i] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = x[i] + 1; j <= x[i] + m; ++j)
      f[i][j] = std::min(f[i - 1][j - x[i]] + 1, f[i][j - x[i]] + 1);
    for (int j = m + 1; j <= m + x[i]; ++j)
      f[i][m] = std::min(f[i][m], f[i][j]);
    for (int j = 1; j <= m - y[i]; ++j)
      f[i][j] = std::min(f[i][j], f[i - 1][j + y[i]]);
    for (int j = 1; j <= l[i]; ++j) f[i][j] = inf;
    for (int j = h[i]; j <= m; ++j) f[i][j] = inf;
  }
  int ans = inf;
  for (int i = 1; i <= m; ++i) { ans = std::min(ans, f[n][i]); }
  if (ans == inf) {
    puts("0");
    ans = 0;
    int i, j;
    for (i = n; i >= 1; i--) {
      for (j = 1; j <= m; j++)
        if (f[i][j] < inf) break;
      if (j <= m) break;
    }
    ans = 0;
    for (j = 1; j <= i; j++)
      if (flag[j]) ans++;
    printf("%d", ans);
  } else {
    puts("1");
    printf("%d", ans);
  }
  return 0;
}